<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试</title>
    <script src="echarts.js" ></script>
</head>
<body>
<div id="main" style="width: 600px;height:600px;border:3px solid red;"></div>
<script>
    var data=[];
    var value=[0, 91, 524 , 6546, 183472];
    var yv=["活跃用户","新用户","连续活跃用户","回流用户","流失用户"];
    var sum =0;
    for (i=0;i<value.length;i++){
        sum += value[i];
    }
<!--    alert(sum)-->

    for ( i=0;i<value.length;i++){
        x=(value[i]/sum ).toFixed(2);
        data.push(x);
    }
    alert(data)
    var xv=[0];
    var a= 0.04;
    var b=0;
    for (i=1;i<=8;i++){
            b=a*i*i;
          xv.push((b*100).toFixed(2)+'%');
        }
<!--    alert(xv)-->
    var option = {
        color:['#ff7f50','#87cefa','#da70d6','#32cd32','#6495ed',
             '#ff69b4','#ba55d3','#cd5c5c','#ffa500','#40e0d0',
             '#1e90ff','#ff6347','#7b68ee','#00fa9a','#ffd700',
             '#6699FF','#ff6666','#3cb371','#b8860b','#30e0e0'],

        title:{x:'left',y:'top',text:"标签人数分布",backgroundColor: 'white',subtext:sum +'人',itemGap:5,
            borderColor: 'white',borderWidth:2,itemGap:5,
            textStyle: {
                fontSize: 20,
                fontWeight: '10',
                color: 'black'
                    },
            subtextStyle: {fontSize: 15,
                        fontWeight: '10',
                        color: 'green'},
             },

        xAxis: {
             type: 'value',
             boundaryGap: false,
<!--             min: 0,-->
<!--             max: 1.1400,-->
<!--            interval: 0.5-->
<!--            axisLabel: {-->
<!--                formatter: function (value, index) {-->
<!--                    return (value * 100).toFixed(2) + "%";-->
<!--                    }-->
<!--                }-->

              },

        yAxis: {data: yv,
             boundaryGap: [0, '50%'],
             type: 'category'
             },

        series: [{name: '销量',type: 'bar',data: value,barWidth : 20,
                label: {
                             normal: {
                                show: true,
                                position: 'right',
                                formatter: function(val){
  		        	return val.data+'人' + '  ' +(val.data/sum * 100).toFixed(2)+'%'
  		                  }
                       }
                     }
                }
               ]

    };
    var myChart = echarts.init(document.getElementById('main'));
    myChart.setOption(option);

</script>

</body>
</html>